package com.aaa.service.SAS.impl;

import com.aaa.dao.SASaplaneMapper;
import com.aaa.entity.MyPage;
import com.aaa.entity.SASaPlane;
import com.aaa.service.SAS.SASaPlaneService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mysql.fabric.xmlrpc.base.Data;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;
@Service
public class SASaPlaneServicelmpl implements SASaPlaneService {
    @Autowired
    private SASaplaneMapper saSaplaneMapper;
    @Override
    public PageInfo queryAll(MyPage myPage) {
        PageHelper.startPage(myPage.getPage(),myPage.getLimit());
        return new PageInfo(saSaplaneMapper.selectAllData());
    }

    @Override
    public boolean selectPlane(SASaPlane plane) {
        List<SASaPlane>select=saSaplaneMapper.select(plane);
        return select.size()==0;
    }

    @Override
    public boolean addPlane(SASaPlane plane) {
        int insert=-1;
            String  planename=plane.getPlanename();
            java.util.Date bengintime=plane.getBegintime();
            java.util.Date endtime=plane.getEndtime();
            String code=plane.getCode();
            int uid=plane.getUid();
            plane.setPlanename(planename);
            plane.setBegintime(bengintime);
            plane.setEndtime(endtime);
            plane.setCode(code);
            plane.setUid(uid);
            insert=saSaplaneMapper.insert(plane);

        return insert>=0?true:false;
    }

    @Override
    public SASaPlane queryByQyCode(SASaPlane saSaPlane) {
        SASaPlane saSaPlane1=saSaplaneMapper.selectOne(saSaPlane);
        return saSaPlane1;
    }
}
